package com.erp.servlet;

import com.erp.bean.Role;
import com.erp.service.RoleService;
import com.erp.service.impl.RoleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zch
 * 角色管理控制器
 */
@WebServlet("/addrole.action")
public class AddRoleServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        RoleService roleService = new RoleServiceImpl();
        String ranme = req.getParameter("rolename");
        Role role = new Role(ranme);
        boolean flag = roleService.add(role);
        System.out.println(flag);
        resp.sendRedirect("rolelist.action");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
